public class ThreadDemo14task {
    public static void main(String[] args) {
        //请完成以下多线程编程：顺序打印
        //有三个线程，线程名称分别为：a，b，c。
        //
        //每个线程打印自己的名称。
        //
        //
        //
        //需要让他们同时启动，并按 c，b，a的顺序打印
        Object lock_a = new Object();
        Object lock_b = new Object();
        Object lock_c = new Object();
        Object lock = new Object();
        Thread a = new Thread(()->{
            /*try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }*/
            synchronized (lock_a) {
                try {
                    lock_a.wait();
                    System.out.println("a\n");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        Thread b = new Thread(()->{

            synchronized (lock) {
                try {
                    lock.wait();
                    System.out.println("b\n");

                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
            synchronized (lock_a){
                lock_a.notify();
            }
        });

        Thread c = new Thread(()->{
            //
            synchronized (lock){
                System.out.println("c\n");
                lock.notify();
            }
        });

        a.start();
        b.start();
        c.start();







    }
}
